Skip to content

Conversation

@natecook1000
Copy link
Member

Work in Progress


Description

Methods for finding the first, last, or all ranges of a given subsequence.

Detailed Design

TK

Documentation Plan

Guide and docs to come…

Test Plan

Initial unit tests included.

Source Impact

This is an additive change only.

Checklist

  • I've added at least one test that validates that my change is working, if appropriate
  • I've followed the code style of the rest of the project
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary

@CTMacUser
Copy link
Contributor

You could probably generalize the Collection.firstRange(of:) method (and therefore BidirectionalCollection.lastRange(of:) too) with an equivalence predicate and/or letting the collections differ in Element type. The given predicate would be allowed to throw.

@karwa
Copy link
Contributor

karwa commented Nov 26, 2020

Have you seen @milseman ’s CollectionSearcher prototype? https://forums.swift.org/t/prototype-protocol-powered-generic-trimming-searching-splitting/29415

I wonder if that would serve as a useful base to include in this library. We could implement things like the generic 2-way search algorithm and Z algorithm mentioned in that post.

@natecook1000
Copy link
Member Author

@CTMacUser and @karwa Absolutely, still exploring the API surfaces here. Thanks!

@natecook1000
Copy link
Member Author

@swift-ci Please test

@natecook1000
Copy link
Member Author

This functionality is handled by the string-processing package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants